home *** CD-ROM | disk | FTP | other *** search
- { Program to increment an environment variable in batch files. Original }
- { reason was to automate POV 2.0 animations with a simple batch file. }
- { See TEST.BAT for a useable example. If PovClock seems to be having }
- { problems setting up the environment, make sure you're running straight }
- { from DOS, and not from a shell or program launcher. }
- { }
- { For example: }
- { PovClock 0 360 50 }
- { will loop for 50 frames from 0 to 360 when put in a batch file. }
- { }
- { Freeware for the whole world to enjoy. If you make any neat additions, }
- { I'd like to set them! }
- { }
- { Mitchell Ross Internet: MRoss@Opie.BGSU.Edu }
- { 3670 Road 5-1 CI$: 70324,241 }
- { Delta, OH 43515 }
- { }
- { 11-12-93 Program Written }
-
- Program ClockCounter;
-
- Uses DOS,EnvUnit; { EnvUnit is an old freeware unit to }
- { modify the DOS environment. }
-
- Var OldClock,StartVal,StopVal,TotalSteps : LongInt;
-
- {---------------------------------}
- Function ValWd( WorkString : String) : LongInt; { String => Int }
-
- Var z : Integer;
- Work : LongInt;
-
- Begin
- Work := 0;
- Val( WorkString,Work,z);
- ValWd := Work;
- End;
-
- {---------------------------------}
- Function Strng( Number : Real; Size,Deci : Integer ) : String;
-
- Var Work : String; { Int => String }
-
- Begin
- If Size < Deci Then Size := Deci;
- Work := '';
- Str(Number:Size:Deci,Work);
- Strng := Work;
- End;
-
- {----------------------------}
- Function ZeroPad( InStr : String; Size : integer ) : String;
-
- Const Zeros = '00000000000000'; { pad front with "0"'s }
-
- begin
- ZeroPad := Copy(Zeros,1,Size-(Length(InStr)))+InStr;
- end;
-
- {---------------------------------}
- {---------------------------------}
- begin
- If ParamCount <> 3 then begin
- Writeln('POVCLOCK By Mitchell Ross');
- Writeln;
- Writeln('Syntax: POVCLOCK StartVal StopVal StepsBetween');
- Writeln('Must have environment var "POVCLOCK=000" before first run');
- Writeln('Each run will step POVCLOCK to next value');
- HALT;
- end;
-
- StartVal := Valwd(ParamStr(1));
- StopVal := Valwd(ParamStr(2));
- TotalSteps := Valwd(ParamStr(3));
- OldClock := Valwd(GetEnv('POVCLOCK')); { get old CLOCK value }
-
- OldClock := OldClock + TRUNC((StopVal-StartVal+1) / TotalSteps);
-
- UseRootPSP;
- If (SetEnv('POVCLOCK',ZeroPad(Strng(OldClock,0,0),3)) = FALSE) then begin
- Writeln('Error setting up environment!');
- end ELSE begin
- Writeln('New POVCLOCK setting: ',Strng(OldClock,3,0));
- end;
- end.